The 7 segment digit display works like this:
- 0 for discharging
- I for battery In
- S for Slow Charging
- H for High (Normal) charging
- P for Fail to detect Peak
- F for Finish charging , or Trickle reflex charging
- E -for Error
- E A - for Error on Acc (battery removed while charging)

This is the schematic used for the 7segment display( I had 2 digits glued together so I made a separate PCB for this 2 digit display but only one connected to PIC )

The the switch (Ra5 to GND) could be omitted .It's function is not implemented yet.

The diode is a cheap 3A (not a Schotky diode becouse you need at least 0.6V on it .)When Lm317 is turned off it still outputs 1.25V-1.3V .So :
1.25V-0.65V= 0.6V on out when Lm317 is turned off.In practice I obtained 0.75V (the Delta Sigma ADC has some influence ).
This voltage is used to detect if at least one element is attached .After you build the circuit , with PIC removed , you must check this voltage to be soure that everything working fine.The software need at least 0.92V to detect one element , so this voltage must be in range of 0.6V-0.92V .